<template>
  <view class="layout-header" :style="{ backgroundColor: color }">
    <view
      class="layout-status"
      :style="{ height: statusBarHeight + 'px' }"
    ></view>
    <view class="layout-bottom" :style="{ height: navHeight + 'px' }">
      <view class="layout-back" :style="{ top: navHeight / 4 }">
        <uni-icons type="back" size="20" color="#131D28"></uni-icons>
      </view>
      <view class="layout-title" :style="{ color: '#000' }">
        {{ title }}
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      navHeight: "", //导航栏高度
      statusBarHeight: "", //状态栏高度
    };
  },
  props: {
    color: {
      type: String,
      default: "#f6f6f6",
    },
    title: {
      type: String,
    },
  },
  created() {
    //mixin里面获取导航栏高度\状态栏高度\头部总高度
    const { navHeight, statusBarHeight } = this.headerHeight();
    this.navHeight = navHeight;
    this.statusBarHeight = statusBarHeight;
  },
};
</script>

<style lang="scss" scoped >
.layout-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
}
.layout-bottom {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  .layout-back {
    position: absolute;
    // top: 50%;
    // margin-top: -10rpx;
    left: 38rpx;
  }
}
</style>